#include <array>
#include <iostream>
#include <string>
#include "GuidTest.h"

using namespace SystemTool;

struct GuidArr
{
    std::array<uint8_t, 16> bytesArr;
};

static void GetGuidBuffer(GuidArr& arr)
{
#ifdef WORDS_BIGENDIAN
    std::swap(arr.bytesArr[0], arr.bytesArr[3]);
    std::swap(arr.bytesArr[1], arr.bytesArr[2]);
    std::swap(arr.bytesArr[4], arr.bytesArr[5]);
    std::swap(arr.bytesArr[6], arr.bytesArr[7]);
#endif
}

void GuidTest()
{
    std::string strUuid = Guid::CreateByRandom().ToString();
    std::cout << strUuid << std::endl;

    Guid id = Guid::FromString("95c0da2d-83d4-4e71-a5ec-cb71d1251217");
    std::cout << id.ToString() << std::endl;

    Guid id2 = Guid::FromString("erwerwer");
    std::cout << id2.ToString() << std::endl;

    GuidArr arr={{0x38, 0x11, 0x09, 0x02, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71}};
    GetGuidBuffer(arr);
    Guid id3 = Guid::CopyFrom((char*)arr.bytesArr.data());
    std::cout << id3.ToString() << std::endl;

    std::array<uint8_t, 16> buffer2;
    id3.CopyTo((char*)buffer2.data());
    if(arr.bytesArr == buffer2)
    {
        std::cout << "They are the same!\n";
        return;
    }
    std::cout << "They are not the same!\n";
}
